package von.seiji.cn.thread;

import cn.hutool.core.util.RandomUtil;
import com.google.common.collect.Lists;

import java.util.ArrayList;
import java.util.Random;

/**
 * @Author: SeiJi
 * @DateTime: 2022/2/7 15:44
 * @Description: 此人很懒，未写描述！
 **/
public class T0 {

    public static void main(String[] args) {
        ArrayList<Thread> list = Lists.newArrayList();
        long l = System.currentTimeMillis();
        for (int i = 0; i < 1020; i++) {
            Operation operation = new Operation(new Random().nextInt(10));
            Thread thread = new Thread(operation, "NO." + (i + 1));
            list.add(thread);
        }
        list.stream().forEach(Thread::start);
        list.stream().forEach(item -> {
            try {
                item.join();
            } catch (InterruptedException e) {}
        });
        System.out.println("consumer time: " + (System.currentTimeMillis() - l) + "ms");
    }
}
